tsset case_id year, yearly

gen demo_lag=demo[_n-1]
replace demo_lag=. if case_id!=case_id[_n-1]

gen demo_change_lag=demo_change[_n-1]
replace demo_change_lag=. if case_id!=case_id[_n-1]

gen real_dem_lag=real_dem[_n-1]
replace real_dem_lag=. if case_id!=case_id[_n-1]

gen real_aut_lag=real_aut[_n-1]
replace real_aut_lag=. if case_id!=case_id[_n-1]

gen gdppc_lag=gdppc[_n-1]
replace gdppc_lag=. if case_id!=case_id[_n-1]

gen infant_lag=infant[_n-1]
replace infant_lag=. if case_id!=case_id[_n-1]

gen infant_change_lag=infant_change[_n-1]
replace infant_change_lag=. if case_id!=case_id[_n-1]

gen life_exp_lag=life_exp[_n-1]
replace life_exp_lag=. if case_id!=case_id[_n-1]

gen lndur=ln(duryrs)

gen lnbds=ln(bds_1000)

gen lnref=ln(ref_1000)

gen lnpop=ln(pop)


btscs recur pcedur_yr case_id,gen(nowtime) nspl(3)

logit recur vic peace part ethnic totalg lnbds lndur infant_lag demo_lag elf pcedur_yr year _spline1 _spline2 _spline3, cluster(country) 

logit recur vic peace part ethnic totalg lnbds lndur lnref infant_lag demo_lag elf pcedur_yr year _spline1 _spline2 _spline3, cluster(country) 

logit recur vic peace part ethnic totalg lnbds lndur life_exp_lag demo_lag elf pcedur_yr year _spline1 _spline2 _spline3, cluster(country) 

logit recur vic peace part ethnic totalg lnbds lndur gdppc_lag demo_lag elf pcedur_yr year _spline1 _spline2 _spline3, cluster(country) 

logit recur vic peace part ethnic totalg lnbds lndur demo_lag infant_change_lag demo_change_lag elf pcedur_yr year _spline1 _spline2 _spline3, cluster(country) 

logit recur vic peace part ethnic totalg lnbds lndur infant_lag real_dem_lag real_aut_lag elf pcedur_yr year _spline1 _spline2 _spline3, cluster(country)



logit recur govwin rebwin peace cease pko eth_rev sec_ lnbds lndur perc_mil infant_lag gdppc_lag demo_lag lnpop pcedur_yr, cluster(country) 

logit recur govwin rebwin peace cease pko eth_rev sec_ lnbds lndur perc_mil infant_lag gdppc_lag demo2 lnpop pcedur_yr, cluster(country) 

logit recur govwin rebwin neg_pko neg_nopko eth_rev sec_ lnbds lndur perc_mil infant_lag gdppc_lag demo2 lnpop pcedur_yr, cluster(country) 

logit recur rebwin neg_pko neg_nopko eth_rev sec_ lnbds lndur perc_mil infant_lag gdppc_lag demo2 lnpop pcedur_yr, cluster(country) 

******************************************************************************************************************************************************************

logit recur csindex ddrtime sp_pop_0014_to_zs vic peace part ethnic totalg lnbds lndur infant_lag demo_lag elf pcedur_yr year _spline1 _spline2 _spline3, cluster(country) 

logit recur csindex ddrtime sp_pop_0014_to_zs govwin rebwin peace cease pko eth_rev sec_ lnbds lndur perc_mil infant_lag gdppc_lag demo_lag lnpop pcedur_yr, cluster(country) 

logit recur c.csindex##ddrtime sp_pop_0014_to_zs vic peace part ethnic totalg lnbds lndur infant_lag demo_lag elf pcedur_yr year _spline1 _spline2 _spline3, cluster(country)
margins ddrtime, at((mean) _all csindex=(1(1)3))
marginsplot

logit recur c.csindex##i.ddrtime sp_pop_0014_to_zs govwin rebwin peace cease pko eth_rev sec_ lnbds lndur perc_mil infant_lag gdppc_lag demo_lag lnpop pcedur_yr, cluster(country) 
margins ddrtime, at((mean) _all csindex=(1(1)3))
marginsplot

******************************************************************************************************************************************************************

sum recur csindex ddr_new sp_pop_0014_to_zs vic govwin rebwin peace cease part pko ethnic eth_rev totalg sec_ lnbds lndur perc_mil infant_lag gdppc_lag demo_lag elf lnpop pcedur_yr year _spline1 _spline2 _spline3
collin csindex ddr_new sp_pop_0014_to_zs vic peace part ethnic totalg lnbds lndur infant_lag demo_lag elf
collin csindex ddr_new sp_pop_0014_to_zs govwin rebwin peace cease pko eth_rev sec_ lnbds lndur perc_mil infant_lag gdppc_lag demo_lag lnpop

logit recur csindex ddr_new sp_pop_0014_to_z pcedur_yr year _spline1 _spline2 _spline3, cluster(country)

logit recur csindex ddr_new sp_pop_0014_to_z pcedur_yr, cluster(country)

logit recur csindex ddr_new sp_pop_0014_to_zs vic peace part ethnic totalg lnbds lndur infant_lag demo_lag elf pcedur_yr year _spline1 _spline2 _spline3, cluster(country) 

logit recur c.csindex##i.ddr_new sp_pop_0014_to_zs vic peace part ethnic totalg lnbds lndur infant_lag demo_lag elf pcedur_yr year _spline1 _spline2 _spline3, cluster(country) 
margins, dydx(csindex) at(ddr_new=(0(1)1)) vsquish level(90)
marginsplot, yline(0) level(90) scheme(lean1) aspectratio(1) name(graph1)

logit recur csindex ddr_new sp_pop_0014_to_zs govwin rebwin peace cease pko eth_rev sec_ lnbds lndur perc_mil infant_lag gdppc_lag demo_lag lnpop pcedur_yr, cluster(country) 

logit recur c.csindex##i.ddr_new sp_pop_0014_to_zs govwin rebwin peace cease pko eth_rev sec_ lnbds lndur perc_mil infant_lag gdppc_lag demo_lag lnpop pcedur_yr, cluster(country) 
margins, dydx(csindex) at(ddr_new=(0(1)1)) vsquish level(90)
marginsplot, yline(0) level(90) scheme(lean1) aspectratio(1) name(graph2)

graph combine graph1 graph2, ycommon

biprobit (recur= csindex ddr_new vic peace part ethnic totalg infant_lag demo_lag elf pcedur_yr year _spline1 _spline2 _spline3) (cs_dummy= lnbds sp_pop_0014_to_zs lndur), cluster( country ) level(90)

biprobit (recur= csindex ddr_new govwin rebwin peace cease pko eth_rev sec_ perc_mil infant_lag gdppc_lag demo_lag lnpop pcedur_yr) (cs_dummy=lnbds sp_pop_0014_to_zs lndur), cluster( country ) level(90)

******

estsimp logit recur csindex ddr_new sp_pop_0014_to_z pcedur_yr year _spline1 _spline2 _spline3, cluster(country)
setx median
simqi, fd(prval(1)) changex(csindex min max) level(90)
simqi, fd(prval(1)) changex(ddr_new min max) level(90)
simqi, fd(prval(1)) changex(sp_pop_0014_to_z min max) level(90)
drop b*

estsimp logit recur csindex ddr_new sp_pop_0014_to_z pcedur_yr, cluster(country)
setx median
simqi, fd(prval(1)) changex(csindex min max) level(90)
simqi, fd(prval(1)) changex(ddr_new min max) level(90)
simqi, fd(prval(1)) changex(sp_pop_0014_to_z min max) level(90)
drop b*

estsimp logit recur csindex ddr_new sp_pop_0014_to_zs vic peace ethnic totalg lnbds lndur infant_lag demo_lag elf pcedur_yr year _spline1 _spline2 _spline3, cluster(country) 
setx median
simqi, fd(prval(1)) changex(csindex min max) level(90)
simqi, fd(prval(1)) changex(ddr_new min max) level(90)
simqi, fd(prval(1)) changex(sp_pop_0014_to_z min max) level(90)
drop b*

estsimp logit recur csindex ddr_new sp_pop_0014_to_zs govwin rebwin peace cease pko eth_rev sec_ lnbds lndur perc_mil infant_lag gdppc_lag demo_lag lnpop pcedur_yr, cluster(country) 
setx median
simqi, fd(prval(1)) changex(csindex min max) level(90)
simqi, fd(prval(1)) changex(ddr_new min max) level(90)
simqi, fd(prval(1)) changex(sp_pop_0014_to_z min max) level(90)
drop b*


























